var e = require;
var t = module;
var n = exports;
Object.defineProperty(n, "__esModule", {value: !0}), (n.playerWar = n.warDealCountData = void 0);
function x() {}
var L = e("Excelchallenge_area1"),
    M = e("Excelchallenge_cointype1"),
    R = e("Excelchallenge_deal1"),
    a = e("Excelchallenge_guide"),
    s = e("index"),
    o = e("user-data"),
    j = e("player-coin"),
    F = e("player-info");
n.warDealCountData = x;
(i.prototype.getWarGuideCellCount = function () {
    return this.warGuideCellCount;
}),
    (i.prototype.getIsGuideLevel = function () {
        return this.isGuideLevel;
    }),
    (i.prototype.setIsGuideLevel = function (e) {
        this.isGuideLevel = e;
    }),
    (i.prototype.getWarLevel = function () {
        return this.curLevel;
    }),
    (i.prototype.setWarLevel = function (e) {
        this.curLevel = e;
    }),
    (i.prototype.getWarLevelTime = function (e) {
        e = o.userData.getLocalData()["war_time" + e];
        return null == e ? 0 : e;
    }),
    (i.prototype.setWarLevelTime = function (e, t) {
        var n = {};
        (n["war_time" + e] = t), o.userData.setLocalData(n);
    }),
    (i.prototype.getWarLevelUnlock = function (e) {
        e = o.userData.getLocalData()["war_level" + e];
        return null != e && e;
    }),
    (i.prototype.setWarLevelUnlock = function (e, t) {
        var n = {};
        (n["war_level" + e] = t), o.userData.setLocalData(n);
    }),
    (i.prototype.getArea = function (e) {
        return (
            (e < 0 || e >= L.default.Data.length) && console.error("war getArea error:", e, L.default.Data.length),
            L.default.GetLine(e + 1)
        );
    }),
    (i.prototype.randCoinCount = function (e, t) {
        for (var n = s.randomInt(1, e), o = 0, i = 0, r = 0; r < t.length; r++) {
            var a = t[r];
            if ((o += a.probability) >= n) {
                i = a.getCoinNum;
                break;
            }
        }
        return i;
    }),
    (i.prototype.getInitData = function (e) {
        (e < 0 || e >= L.default.Data.length) && console.error("war getInitData error:", e, L.default.Data.length);
        for (var t = new Map(), n = 0; n < M.default.Data.length; n++) {
            var o = (g = M.default.Data[n])["coinNum" + (e + 1)];
            o && t.set(g.coinType, o);
        }
        for (var i = 0, r = [], n = 0; n < R.default.Data.length; n++) {
            var a,
                s,
                c = (g = R.default.Data[n])["challenge" + (e + 1)];
            c &&
                ((s = c.split("#")),
                (a = Number(s[0])),
                (c = Number(s[1])) &&
                    0 < c &&
                    (((s = new x()).getCoinNum = a), (s.probability = c), r.push(s), (i += c)));
        }
        var l = this.getArea(e),
            u = j.playerCoin.getCoinMaxCount(),
            p = l.column * l.row,
            h = new Map(),
            d = new Map(),
            f = new Map(),
            m = new Map(),
            y = l.adArea1.split("#");
        for (n = 0; n < y.length; n++) {
            var g = y[n],
                v = Number(g);
            v && 0 < v && m.set(v, !0);
        }
        var b,
            _ = l.emptyArea.split("#");
        for (n = 0; n < _.length; n++) {
            var g = _[n],
                w = Number(g);
            w && 0 < w && m.set(w, !0);
        }
        for (n = 0; n < p; n++)
            if (!m.has(n)) {
                h.set(n, []);
                for (var C = new Map(), k = 0; k < 50; k++) {
                    var S = [],
                        I = 0;
                    t.forEach(function (e, t) {
                        var n;
                        0 < e && (((n = new x()).getCoinNum = t), (n.probability = e), S.push(n), (I += e));
                    });
                    var T = this.randCoinCount(I, S);
                    if (t.has(T)) {
                        for (
                            var O = t.get(T),
                                N = this.randCoinCount(i, r),
                                D = u - h.get(n).length,
                                P = ((a = Math.min(O, N, D)), 0);
                            P < a;
                            P++
                        ) {
                            var E = new F.saveCoinData();
                            E.num = T;
                            var A = h.get(n);
                            A.push(E), h.set(n, A);
                        }
                        if ((C.set(T, !0), 0 < O - a ? t.set(T, O - a) : t.delete(T), u <= h.get(n).length)) {
                            1 === C.size ? f.set(n, T) : 3 <= C.size && d.set(n, C);
                            break;
                        }
                    }
                }
            }
        return (
            0 < f.size &&
                (d.size < f.size && console.log("moreThreeIdxs.size..error:", d.size, f.size),
                console.log("getInitData....", f),
                (b = f.keys()),
                d.forEach(function (e, s) {
                    var c,
                        l,
                        u = b.next();
                    void 0 !== u.value &&
                        ((c = f.get(u.value)),
                        (l = !1),
                        e.forEach(function (e, t) {
                            if (t !== c && !l) {
                                l = !0;
                                for (var n = h.get(s), o = h.get(u.value), i = 0; i < n.length; i++) {
                                    var r = n[i],
                                        a = o[i];
                                    r.num === t && ((r.num = a.num), (a.num = t));
                                }
                            }
                        }));
                })),
            h
        );
    }),
    (i.prototype.getGuideData = function () {
        for (var e = new Map(), t = 0; t < a.default.Data.length; t++)
            for (var n = a.default.Data[t], o = 0; o < this.getWarGuideCellCount(); o++) {
                var i,
                    r = n["place" + (o + 1)];
                r &&
                    (e.has(o) || e.set(o, []),
                    ((i = new F.saveCoinData()).num = r),
                    (r = e.get(o)).unshift(i),
                    e.set(o, r));
            }
        return e;
    }),
    (i.prototype.getWarLevelCount = function (e) {
        e = o.userData.getLocalData()["war_count" + e];
        return null == e ? 0 : e;
    }),
    (i.prototype.setWarLevelCount = function (e, t) {
        var n = {};
        (n["war_count" + e] = t), o.userData.setLocalData(n);
    }),
    (i.prototype.getUseADAreaCount = function () {
        return this.warUseADAreaCount;
    }),
    (i.prototype.setUseADAreaCount = function (e) {
        this.warUseADAreaCount = e;
    }),
    (e = i);
function i() {
    (this.curLevel = 0), (this.isGuideLevel = !1), (this.warGuideCellCount = 3), (this.warUseADAreaCount = 0);
}
n.playerWar = new e();
